
import org.apache.commons.beanutils.PropertyUtils;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import java.util.List;

@Service
public class RmsMaterialUsageConfigServiceImpl implements RmsMaterialUsageConfigService  {

    @Resource
    private RmsMaterialUsageConfigMapper rmsMaterialUsageConfigMapper;

    /**
     * 获取 RmsMaterialUsageConfig 分页列表
     */
    @Transactional
    public IPage getRmsMaterialUsageConfigPagination( PaginationVo paginationVo, RmsMaterialUsageConfigQuery rmsMaterialUsageConfigQuery ) throws Exception {

        IPage page = new Page( paginationVo.getPageIndex(), paginationVo.getPageSize() );
        LambdaQueryWrapper<RmsMaterialUsageConfigEntity> lqs = new LambdaQueryWrapper();
        rmsMaterialUsageConfigMapper.selectPage(page, lqs);

        List<RmsMaterialUsageConfigEntity> record = page.getRecords();
        if( !ObjectUtil.isNotEmptyList(record)){
            return page;
        }
        return null;
    }


    /**
     * 获取 RmsMaterialUsageConfig 所有数据
     *
    */
    @Transactional
    public List<RmsMaterialUsageConfigEntity> getRmsMaterialUsageConfigAllList( RmsMaterialUsageConfigQuery rmsMaterialUsageConfigQuery ) throws Exception {

        LambdaQueryWrapper<RmsMaterialUsageConfigEntity> lqs = new LambdaQueryWrapper();
        List<RmsMaterialUsageConfigEntity> list = rmsMaterialUsageConfigMapper.selectList(lqs);
        return list;
    }


    /**
     * 获取 RmsMaterialUsageConfig 详情
    */
    @Transactional
    public RmsMaterialUsageConfigEntity getRmsMaterialUsageConfigDetail( Long id) throws Exception {

        RmsMaterialUsageConfigEntity rmsMaterialUsageConfig = rmsMaterialUsageConfigMapper.selectById(id);
        return rmsMaterialUsageConfig;
    }


    /**
     * 新增 RmsMaterialUsageConfig
     * */
    @Transactional
    public void addRmsMaterialUsageConfig(RmsMaterialUsageConfigVo rmsMaterialUsageConfigVo) throws Exception {

        RmsMaterialUsageConfigEntity rmsMaterialUsageConfig = new RmsMaterialUsageConfigEntity();
        ReflectionCopy.copyProperties( rmsMaterialUsageConfig, rmsMaterialUsageConfigVo );
        rmsMaterialUsageConfigMapper.insert(rmsMaterialUsageConfig);
        return;
    }


    /**
     * 更新 RmsMaterialUsageConfig
     * */
    @Transactional
    public void updateRmsMaterialUsageConfig( RmsMaterialUsageConfigVo rmsMaterialUsageConfigVo) throws Exception {

        if( rmsMaterialUsageConfigVo.getId() == null ){
            throw GlobalException.gen(10021, "id不存在");
        }
        RmsMaterialUsageConfigEntity rmsMaterialUsageConfig = new RmsMaterialUsageConfigEntity();
        ReflectionCopy.copyProperties( rmsMaterialUsageConfig, rmsMaterialUsageConfigVo );
        rmsMaterialUsageConfigMapper.updateById(rmsMaterialUsageConfig);
        return;
    }

    /**
     * 删除 RmsMaterialUsageConfig
     * */
    @Transactional
    public void batchRemoveRmsMaterialUsageConfig( List<Long> ids ) throws Exception {


        if( !ObjectUtil.isNotEmptyList(ids) ){
            throw GlobalException.gen(10011, "要删除的id不存在");
        }
        rmsMaterialUsageConfigMapper.deleteBatchIds(ids);
    }

}

      